package com.leyou.item.api;

import com.leyou.item.pojo.Brand;
import com.leyou.common.pojo.PageResult;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Feature:品牌服务接口
 */
@RequestMapping("brand")
public interface BrandApi {

    /**
     * - page：当前页，int
     * - rows：每页大小，int
     * - sortBy：排序字段，String
     * - desc：是否为降序，boolean
     * - key：搜索关键词，String
     */
    @GetMapping("page")
    public PageResult<Brand> queryBrandByPage(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                              @RequestParam(value = "rows", defaultValue = "5") Integer rows,
                                              @RequestParam(value = "sortBy", required = false) String sortBy,
                                              @RequestParam(value = "desc", defaultValue = "false") Boolean desc,
                                              @RequestParam(value = "key", required = false) String key);
    /**
     * 新增品牌
     * @param brand
     * @param categories
     * @return
     */
    @PostMapping
    public ResponseEntity<Void> saveBrand(Brand brand,@RequestParam("categories") List<Long> categories);

    /**
     * 更新品牌
     * @param brand
     * @param categories
     * @return
     */
    @PutMapping
    public ResponseEntity<Void> updateBrand(Brand brand,@RequestParam("categories") List<Long> categories);

    /**
     * 删除品牌
     * @param bid
     * @return
     */
    @DeleteMapping("bid/{bid}")
    public ResponseEntity<Void> deleteBrand(@PathVariable("bid") Long bid);

    /**
     * 删除单个品牌
     * @param bid
     * @return
     */
    @DeleteMapping("cid_bid/{bid}")
    public ResponseEntity<Void> deleteByBrandIdInCategoryBrand(@PathVariable("bid") Long bid);



    /**
     * 根据category的id查询品牌信息
     * @param cid
     * @return
     */
    @GetMapping("cid/{cid}")
    public List<Brand> queryBrandByCategoryId(@PathVariable("cid") Long cid);

    /**
     * 根据品牌id结合，查询品牌信息
     * @param ids
     * @return
     */
    @GetMapping("list")
    public List<Brand> queryBrandByIds(@RequestParam("ids") List<Long> ids);

}
